home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 18 / AMIGAplus Sonderheft 18 (1999)(ICP)(DE)[!].iso / Forum / MichaelRoth / 3-3-99 / ChangeZeile / ChangeZeile.asm < prev   
Assembly Source File  |  1998-08-15  |  4KB  |  157 lines

  1.  
  2. ;// Include
  3.           Include  assem:macro/Dir
  4.           Include  assem:macro/Exec.m
  5.           Include  assem:macro/Dos.m
  6.           Include  Dos/DosExtens.i
  7.           include  macro/filelength
  8. ;\\
  9.  
  10. ;// Libraries öffnen
  11.           OpenDos  37
  12. ;\\
  13.  
  14. ;//ReadArgs
  15.           move.l   #inputstr,d1                  ; Eingabe String
  16.           move.l   #arry,d2                      ; Arry
  17.           move.l   #0,d3                         ; Keine Externe Structur
  18.           Dos      ReadArgs                      ; Argumente Lesen
  19.           move.l   d0,rdargs                     ; speichern
  20.           bne.s    .1                            ; prüfen ob alles o.k.
  21.           error    cleanup,20                    ; o.k. >.1 Ansonsten Fehlermeldung beenden
  22. .1                                               ;
  23.           lea   arry,a0                          ; Arry nach a0
  24. ;\\
  25.  
  26. ;//File Öffnen und gröe bestimmen
  27.           move.l   (a0),d1
  28.           move.l   #MODE_OLDFILE,d2              ; 1005
  29.           Dos      Open                          ; File Öffnen
  30.           bne.s    .2
  31.           error    cleanup,20
  32. .2
  33.           move.l   d0,fh
  34.           filelength fh,filelänge                ; Filelänge bestimmen
  35. ;\\
  36.  
  37. ;// Speicher Reservieren
  38.          move.l    filelänge,d0
  39.          move.l    #MEMF_CLEAR,d1
  40.          Exec      AllocMem
  41.          move.l    d0,memblock
  42.          bne.s     .memallockok
  43.          error     cleanup,20
  44. .memallockok
  45. ;\\
  46.  
  47. ;// File einlesen
  48.          move.l   fh,d1
  49.          move.l   memblock,d2
  50.          move.l   filelänge,d3
  51.          Dos      Read
  52.          cmp.l    filelänge,d0
  53.          beq.s    .readok
  54.          error    cleanup,20
  55. .readok
  56. ;\\
  57.  
  58.  
  59.          move.l   memblock,a0
  60.          move.l   filelänge,d0
  61.  
  62. ; A0 -> Buffer
  63. ; D0 -> Länge des buffers
  64.  
  65.  
  66. ; Sub Register
  67. ; A5 Endadresse
  68. ; A2 Hilfsregister
  69. ; A1 Hilfsregister
  70.          move.l    a0,a1
  71.          lea       (a0,d0),a5
  72.          moveq     #-1,d0
  73. .lop
  74. .loop
  75.          cmp.l     a1,a5                         ; Buffer Am Ende?
  76.          bls.s     .exit                         ; -> Eixt
  77.          cmp.b     #10,(a1)+                     ; Auf CR prüfen
  78.          dbeq      d0,.loop                      ;
  79.          ext.l     d0
  80.          neg.l     d0                            ; Wert negieren um echten Wert zu erhalten
  81.          sub.w     #1,d0                         ; wegen dem CR 1 abziehem
  82.          beq       .goon
  83.          lsr.w     #1,d0                         ; durch 2 Teilen
  84.          tst       d0
  85.          beq       .goon
  86.          sub.w     #1,d0                         ; DBcc schleife Initialisieren
  87.          lea       -1(a1),a2                     ; CR ausblenden
  88. .loop2
  89.          move.b    -(a2),d1                      ; Zeichen am ende auslesen
  90.          move.b    (a0),(a2)                     ; Zeichen austauschen
  91.          move.b    d1,(a0)+                      ; und leztes Zeichen an Anfang stellen
  92.          dbra      d0,.loop2                     ; Kopieren
  93. .goon
  94.          move.l    a1,a0                         ;
  95.          moveq     #-1,d0
  96.          bra       .lop
  97. .exit
  98.  
  99.  
  100. ;// Zielfile Öffnen
  101.          lea       arry,a0                          ; Arry nach a0
  102.          move.l    4(a0),d1
  103.          move.l    #MODE_NEWFILE,d2
  104.          Dos       Open
  105.          move.l    d0,d7
  106.          bne       .ok
  107.          error     cleanup,20
  108. .ok
  109.  
  110.          move.l    d7,d1
  111.          move.l    memblock,d2
  112.          move.l    filelänge,d3
  113.          Dos       Write
  114.  
  115.          move.l    d7,d1
  116.          Dos       Close
  117. ;\\
  118.  
  119.  
  120. ;// CleanUp
  121. cleanup
  122.           move.l   rdargs,d1
  123.           beq.s    .end                          ; Argumente da ?
  124.           Dos      FreeArgs                      ; Wenn Nein beenden
  125.  
  126.           move.l   fh,d1
  127.           beq.s    .1                            ; File geöffnet
  128.           Dos      Close                         ; Wenn nein weiter
  129. .1
  130.           move.l    memblock,d0
  131.           beq.s     .2
  132.           move.l    d0,a1
  133.           move.l    filelänge,d0
  134.           Exec      FreeMem
  135. .2
  136. .end
  137.           closedos
  138.           moveq    #0,d0
  139.           rts
  140. ;\\
  141.  
  142. ;// Data
  143.  DATA
  144. inputstr
  145.          dc.b      "Source/A,Dest/A",0
  146.  BSS
  147.  cnop 0,4
  148. arry     ds.l      2
  149. rdargs   ds.l      1
  150. fh       ds.l      1
  151. filelänge
  152.          ds.l      1
  153. memblock ds.l      1
  154. insert   dc.b      4,0
  155. ;\\
  156.  
  157.